package org.sbbs.app.demo.webapp.action;

import org.sbbs.app.demo.model.DemoSysDbLog;
import org.sbbs.app.demo.service.DemoSysDbLogManager;
import org.sbbs.base.searcher.SearchFilter;
import org.sbbs.base.searcher.SearchFilterBuilder;
import org.sbbs.base.webapp.action.BaseJqgridPagedAction;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.sbbs.base.pagequery.hibernate.CriteriaUtil;
import org.sbbs.base.pagequery.hibernate.CustomCriteria;
import org.sbbs.base.pager.IPager;
import org.sbbs.base.pager.impl.JqgridPagerImpl;
import org.sbbs.base.searcher.SearchOperator;

public class DemoSysDbLogPagedAction
    extends BaseJqgridPagedAction {
    private DemoSysDbLogManager demoSysDbLogManager;

    public DemoSysDbLogManager getDemoSysDbLogManager() {
        return demoSysDbLogManager;
    }

    public void setDemoSysDbLogManager( DemoSysDbLogManager demoSysDbLogManager ) {
        this.demoSysDbLogManager = demoSysDbLogManager;
    }

    @Override
    public Class getSearchEntityClazz() {
        return DemoSysDbLog.class;
    }

    @Override
    public int getSearchFilterType() {
        return SearchFilterBuilder.PROPERTY_FILTER;
    }

    public String gridPageList() {
        try {
            IPager pager = new JqgridPagerImpl( getRequest() );
            SearchFilter sf = SearchFilterBuilder.buildSearchFilter( getRequest(), this.getSearchFilterType() );
            if ( this.getCustomCriteria() != null )
                pager = this.demoSysDbLogManager.pagedQuery( this.getSearchEntityClazz(), pager, sf, this.getCustomCriteria() );
            else
                pager = this.demoSysDbLogManager.pagedQuery( this.getSearchEntityClazz(), pager, sf );

            this.pageList = pager.getList();
            records = pager.getTotalNumberOfRows();
            total = pager.getTotalNumberOfPages();
            page = pager.getPageNumber();
        }
        catch ( Exception e ) {
            log.error( "GridList Error", e );
        }
        return SUCCESS;
    }

}
